package com.matezk.sael.tencent;

import com.tencent.iot.explorer.device.java.data_template.DataTemplateJson;
import com.tencent.iot.explorer.device.java.utils.CustomLog;
import com.tencent.iot.hub.device.java.core.common.Status;

import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TencentDataTemplateJson extends DataTemplateJson {
    private static final Logger LOG = LoggerFactory.getLogger(TencentDataTemplateJson.class);
    private static final CustomLog CUSTOM_LOG = new CustomLog(LOG);


    private Status registerDataTemplateJson(String content) {
        try {
            JSONObject json = new JSONObject(content);
            this.mPropertyJson = json.getJSONArray("properties");
            this.mEventJson = json.getJSONArray("events");
            this.mActionJson = json.getJSONArray("actions");
            return Status.OK;
        } catch (JSONException e) {
            return Status.ERROR;
        }
    }

    public TencentDataTemplateJson(String json) {
        super(CUSTOM_LOG);
        registerDataTemplateJson(json);
    }
}
